﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UtilZ.Dotnet.WindowsDesktopEx.Base
{
    /// <summary>
    /// 部分异步等待类
    /// </summary>
    public abstract class PartAsynWaitAbs
    {
        /// <summary>
        /// 遮罩控件工厂
        /// </summary>
        protected static IShadeControlFactory _shadeControlFactory = null;

        /// <summary>
        /// 遮罩控件工厂
        /// </summary>
        public static IShadeControlFactory ShadeControlFactory
        {
            get
            {
                return _shadeControlFactory;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                _shadeControlFactory = value;
            }
        }


        /// <summary>
        ///  构造函数初始化
        /// </summary>
        public PartAsynWaitAbs()
        {

        }


        /// <summary>
        /// 获取遮罩层控件创建工厂对象
        /// </summary>
        /// <returns></returns>
        protected IShadeControlFactory GetShadeControlFactory()
        {
            if (_shadeControlFactory == null)
            {
                _shadeControlFactory = this.CreateDefaultShadeControlFactory();
            }

            return _shadeControlFactory;
        }


        /// <summary>
        /// 创建默认遮罩层控件创建工厂对象
        /// </summary>
        /// <returns></returns>
        protected abstract IShadeControlFactory CreateDefaultShadeControlFactory();
    }
}
